package cn.edu.seu.cose.qol.model.dto.question;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

@XmlType(name = "briefQuestion", propOrder = {"_contentType", "_body", "_uri"})
@XmlAccessorType(XmlAccessType.FIELD)
public class AddressableQuestionInstance {
	
	@XmlAttribute(name = "type")
	private QuestionContentType _contentType;
	
	@XmlElement(name = "body")
	private String _body;
	
	@XmlElement(name = "uri")
	private String _uri;
	
	public AddressableQuestionInstance() {
		this("", QuestionContentType.NULL);
	}
	
	public AddressableQuestionInstance(String body, QuestionContentType contentType) {
		this(body, contentType, null);
	}
	
	public AddressableQuestionInstance(String body, QuestionContentType contentType,
				String uri) {
		_body = body;
		_contentType = contentType;
		_uri = uri;
		checkContentType();
	}
	
	public String getBody() {
		return _body;
	}
	
	public void setBody(String body) {
		_body = body;
	}
	
	public QuestionContentType getContentType() {
		return _contentType;
	}
	
	public void setContentType(QuestionContentType contentType) {
		_contentType = contentType;
		checkContentType();
	}
	
	public String getUri() {
		return _uri;
	}
	
	public void setUri(String uri) {
		_uri = uri;
	}
	
	private void checkContentType() {
		if (_contentType == null) {
			_contentType = QuestionContentType.NULL;
		}
	}

}
